package com.onlyxiahui.common.message.data;

/**
 * 
 * 
 * 分页信息 <br>
 * Date 2020-02-24 11:57:32<br>
 * 
 * @author XiaHui [onlovexiahui@qq.com]<br>
 * @since 1.0.0
 */

public class Page {

	/**
	 * 页码数，从第1页开始
	 */
	private int number = 1;
	/**
	 * 每页大小
	 */
	private int size = 30;
	/**
	 * 总条数
	 */
	private int totalCount;
	/**
	 * 总页数
	 */
	private int totalPage;

	public int getNumber() {
		return number;
	}

	public void setNumber(int number) {
		this.number = number < 0 ? 0 : number;
	}

	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public int getTotalPage() {
		if (this.getTotalCount() > 0) {
			totalPage = this.getTotalCount() / this.getSize();
			if (this.getTotalCount() % this.getSize() > 0) {
				totalPage = totalPage + 1;
			}
		}
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	/**
	 * 
	 * 
	 * 开始记录数，比如第一页从0开始，第二页 每页30个，从30开始<br>
	 * Date 2019-07-09 10:49:22<br>
	 * 
	 * @return int
	 * @since 1.0.0
	 */
	public int getStartResult() {
		int startResult = 0;
		if (this.getSize() < 0 || this.getNumber() < 0) {
			startResult = 0;
		} else if (startResult > 0) {

		} else {
			startResult = (this.getNumber() - 1) * this.getSize();

			if (startResult < 0) {
				startResult = 0;
			}
		}
		return startResult;
	}
}
